/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/********************************************************************************************************
 *                                      Include header files                                            *
 *******************************************************************************************************/
#include "Compiler.h"

#if defined(__IASMARM__) || defined(__ICCARM__)
        SECTION .mcal_text_asm_mcallib:CODE(2)
        ARM
#elif defined(__ghs__) || defined(__ghs_asm)
        .section ".mcal_text_asm_mcallib"
#else
        .section ".text"
        .arm
#endif

    ASM_PUBLIC read_pmccntr
ASM_FUNCTION(read_pmccntr)   /* counter frequency register */
    mrc p15, 0, r0, c9, c13, 0
    isb
    bx lr
ASM_FUNCTION_END(read_pmccntr)

    ASM_PUBLIC write_pmcr
ASM_FUNCTION(write_pmcr)  /* counter frequency register */
    mcr p15, 0, r0, c9, c12, 0
    bx lr
ASM_FUNCTION_END(write_pmcr)

    ASM_PUBLIC write_pmuserenr
ASM_FUNCTION(write_pmuserenr)  /* pm user mode enable register */
    mcr p15, 0, r0, c9, c14, 0 /* Write PMUSERENR Register */
    bx lr
ASM_FUNCTION_END(write_pmuserenr)

    ASM_PUBLIC write_pmcntenset
ASM_FUNCTION(write_pmcntenset)  /* virtual timer value register */
    mcr p15, 0, r0, c9, c12, 1
    bx lr
ASM_FUNCTION_END(write_pmcntenset)

    ASM_PUBLIC read_pmcnten
ASM_FUNCTION(read_pmcnten)  /* virtual timer value register */
    mrc p15, 0, r0, c9, c12, 1
    bx lr
ASM_FUNCTION_END(read_pmcnten)

#if defined(__IASMARM__) || defined(__ICCARM__)
    END
#endif
/* End of file */
